const mongoose = require('mongoose')

const Schema = mongoose.Schema

const OrderSchema = new Schema(
  {
    order_num: {
      type: Number,
      require: true,
    },
    user: { type: Schema.Types.ObjectId, ref: 'User' },
    rent: {
      type: Number,
      require: true,
    },
    start: {
      type: Number,
      require: true,
    },
    end: {
      type: Number,
      require: true,
    },
    car: { type: Schema.Types.ObjectId, ref: 'Car' },
    shop: { type: Schema.Types.ObjectId, ref: 'Shop' },
  },
  {
    timestamps: { currentTime: () => Date.now() },
  }
)

const OrderModel = mongoose.model('Order', OrderSchema)

module.exports = OrderModel
